#include "Parametros.h"

Parametros::Parametros(QObject */*parent*/) :
    QSettings("IndustriaPadilla", "ClubSanIsidro")
{
    qDebug() << "fileName() :" << fileName();
    initialize();
    readSettings();
    if (!QFile::exists(fileName()))
    {
        qDebug() << "To write at first time";
        writeSettings();
    }
}

Parametros::~Parametros()
{
}

void Parametros::initialize()
{
    firstGroup  = "Conectividad";
    nip = "IP";
    vip = "localhost";
    lip = "";
}

void Parametros::readSettings()
{
    // read ../IndustriaPadilla/ClubSanIsidro.conf
    beginGroup(firstGroup);
//    QPoint  pos     = setting.value("position", QPoint(50, 50)).toPoint();
//    QSize   size    = setting.value("tamanho", QSize(500, 300)).toSize();
    lip  = value(nip, vip).toString();
    qDebug() << "lip r:" << lip;
    endGroup();
}

void Parametros::writeSettings()
{
    // write ../IndustriaPadilla/ClubSanIsidro.conf
    beginGroup(firstGroup);
//    QPoint  pos     = setting.value("position", QPoint(50, 50)).toPoint();
//    QSize   size    = setting.value("tamanho", QSize(500, 300)).toSize();
//    lip  = value(nip, vip).toString();
    qDebug() << "lip w:" << lip;
    setValue(nip, lip);
    endGroup();
}
